﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

using System.Text;
using System.Windows.Forms;
using ArcEngine.Resources;


namespace ArcEngine.Editor.Wizards
{
	public partial class NewScriptWizard : Form
	{

		/// <summary>
		/// 
		/// </summary>
		public NewScriptWizard()
		{
			InitializeComponent();

			foreach (string item in Enum.GetNames(typeof(ScriptLanguage)))
			{
				LanguageBox.Items.Add(item);
			}
			LanguageBox.SelectedItem = ScriptLanguage.CSharp.ToString();
	
		}


		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void NewScriptWizard_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (DialogResult != DialogResult.OK)
				return;

			// Script already exists ?
			if (ResourceManager.GetScript(ScriptNameBox.Text) != null || ScriptNameBox.Text == "")
			{
				MessageBox.Show("Script name already in use or invalid. Use another name !");
				e.Cancel = true;
				return;
			}


			// Adds the texture file as a binary
			Script script = ResourceManager.CreateScript(ScriptNameBox.Text);
			script.Language = Language;


		}


		#region Properties


		/// <summary>
		/// Language of the script
		/// </summary>
		ScriptLanguage Language
		{
			get
			{
				return (ScriptLanguage) Enum.Parse(typeof(ScriptLanguage), LanguageBox.SelectedItem.ToString());
			}
		}

		#endregion
	}
}
